<template>
    <view>
        <web-view @message="handlePostMessage" :src="url"></web-view>
    </view>
</template>

<script>
    
export default {
    data() {
        return {
            token:'',
            url:'',
            time:null
        };
    },
    onLoad(options) {
        let _this = this
        this.token = this.$getSync('userToken')
        this.url = "https://xcx.dbywuliuyunshugl.com/h5/?token="+this.token;
        
        console.log(this.url)
        this.time = setInterval(function(){
            _this.getUserInfo()
        },3000)
    },
    onShow: function() {
    },
    onHide() {
        clearInterval(this.time);
        this.time = null
    },
    onUnload() {
        clearInterval(this.time);
        this.time = null
    },
    methods: {
        // 获取用户信息
        async getUserInfo() {
            let { msg, success, detail } = await this.$ajax('driver_detail', {
                user_token: uni.getStorageSync('userToken')
            });
            if (success == 1000) {
                this.userInfo = detail;
                if (this.userInfo.official_openid) {
                    clearInterval(this.time);
                    uni.switchTab({
                    	url: '/pages/tabbar/driver-mine'
                    });
                }
            } else {
                this.$toast(msg);
            }
        },
    }
};
</script>

<style>
    
</style>
